"""
Encapsulate fetching content of HTTP in one place.
"""

from urllib.request import urlopen
from urllib.error import HTTPError
import logging

def fetch(uri):
    """
    Retrieve the content at uri.
    """
    with urlopen(uri) as response:
        if response.status != '200':
            logging.debug(response.info(), response)
            raise HTTPError('bad status when fetching profile data: %s'.format(response.status))
        return response.read()
